<!DOCTYPE html>
<html lang="en">
<title>新增消息</title> <#import "/layout/layout.html" as body/>
<@body.page>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<div class="row wrapper border-bottom white-bg page-heading">
	<div class="col-lg-10">
		<h2>运营管理</h2>
		<ol class="breadcrumb">
			<li><a href="#">运营管理</a></li>
			<li class="active"><strong>新增消息</strong></li>
		</ol>
	</div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-lg-12">
			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<h5 class="pull-left">新增消息</h5>
				</div>
				<div class="ibox-content">
					<form method="post" id="addForm" class="form-horizontal">
						<input type="hidden" id="id" name="id" value="${courseNoticeInfo.id!}" />
						<div class="form-group"><label class="col-sm-2 control-label">标题</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="title" name="title" placeholder="非必填，如不填写，则默认为：下周的檬课表更新啦，快来和檬教练们一起锻炼吧！" value="${courseNoticeInfo.title!}">
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						<div class="form-group">
							<label class="col-sm-2 control-label">上课地点</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="storeids" name="storeids" placeholder="非必填，如不填写，则默认陈列营业中的门店名称" value="${courseNoticeInfo.storeids!}">
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						<div class="form-group"><label class="col-sm-2 control-label">发送时间</label>
							<div class="col-sm-10">
								<div class="input-group date form_datetime" data-date-format="yyyy-mm-dd hh:ii" data-link-field="dtp_input1">
									<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
									<input id="sendtime" name="sendtime" class="form-control" size="16" type="text" placeholder="设置课程通知的发送时间" readonly value="${sendtime!}">
								</div>
							</div>
						</div>
						<div class="hr-line-dashed"></div>
					</form>
				</div>
				<div class="ibox-content overflow">
					<div class="col-sm-12">
						<button type="button" class="btn btn-default pull-left" onclick="goBackList()">取消添加</button>
						<button type="button" id="saveBtn" class="btn btn-primary pull-right" onclick="submitForm()">确认发送</button>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
    $(document).ready(function () {
        $('#sendtime').datetimepicker({
            language: 'zh-CN',
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            showMeridian: 0
        });
    });
    function goBackList(){
    	window.location = "to_notice_list";
    }
    
    function submitForm(){
    	var isCheck = true;
    	 if ($("#sendtime").val().length <= 0) {
             swal("错误!", "请填写发送时间!", "error");
             isCheck = false;
             return false;
         }
       var param = $("#addForm").serialize();
       $("#saveBtn").attr('disabled', "true");
       $.ajax({
           type: "post",
           url: "course_notice_add",
           data: param,
           success: function (data) {
        	   debugger
               if (data == "success") {
                   swal("保存成功!", "页面即将重新加载,请稍后...", "success");
                   window.setTimeout(function () {
                       window.location = "to_notice_list"
                   }, 1000);
                   $("#saveBtn").attr('disabled', "flase");
               } else {
                   swal("保存失败!", data, "error");
                   $("#saveBtn").attr('disabled', "flase");
               }
           }
       });
    }
</script>
</@body.page>
</html>